﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using BLL;
using BOL;
using DAL;
using DevComponents.AdvTree;

namespace QLThueMuonXe
{
    public partial class frmChiTieThongKe : Form
    {

        public frmChiTieThongKe()
        {
            InitializeComponent();
        }
        FormThongKeChiTiet ftkct = new FormThongKeChiTiet();
        public string maxe;
        public DateTime tungay;
        public DateTime denngay;

        private Node CreateXeRow(string maxe, string hangxe, string tenxe, string ngaythue, string giobatdau, string tongtg, string giathue, string tongtien, bool thanhtoan)
        {
            string tt;
            if(thanhtoan) tt = "Rồi"; else tt = "Chưa";            
            Node node = new Node(maxe);
            node.Cells.Add(new Cell(hangxe));
            node.Cells.Add(new Cell(tenxe));
            node.Cells.Add(new Cell(ngaythue));
            node.Cells.Add(new Cell(giobatdau));
            node.Cells.Add(new Cell(tongtg));
            node.Cells.Add(new Cell(giathue));
            node.Cells.Add(new Cell(tongtien));
            node.Cells.Add(new Cell(tt));
            return node;
        }


        public void TKLoad()
        {
            List<ThongKe> ttx = ftkct.ThongKeTongHop(maxe, tungay, denngay);
            advTree1.Nodes.Clear();
            foreach (var row in ttx)
            {
                advTree1.Nodes.Add(CreateXeRow(row.MaXe, row.HangXe, row.TenXe, row.NgayThue.ToString("MM/dd/yyyy"), row.NgayThue.Hour +":"+ row.NgayThue.Minute,""+row.GioThue+"giờ "+ row.PhutThue+"phút",string.Format("{0:#,0.#}", row.GiaThue) , string.Format("{0:#,0.#}",row.TongGiaThue), row.thanhtoan));
            }
            advTree1.SelectedIndex = 0;
        }

        private void frmChiTieThongKe_Load(object sender, EventArgs e)
        {
            lblmaxe.Text = maxe;
            lbltungay.Text = tungay.ToString("MM/dd/yyyy");
            lbldenngay.Text = denngay.ToString("MM/dd/yyyy");
            TKLoad();
        }

    }
}
